package com.eco.fanliapp.controller.app;

import com.eco.fanliapp.common.base.BaseController;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.entity.AppUser;
import com.eco.fanliapp.entity.AppUserRedReward;
import com.eco.fanliapp.service.IAppUserRedRewardService;
import com.github.pagehelper.PageInfo;
import lombok.Synchronized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

/**
 * @ProjectName: fanliapp
 * @Package: com.eco.fanliapp.controller.app
 * @ClassName: AppUserRedRewardController
 * @Author: xiaoxx
 * @Description: 用户红包和任务
 * @Date: 2019/11/28 15:13
 * @Version: 4.2.2
 */
@RestController
@RequestMapping("/mobile/reward")
public class AppUserRedRewardController extends BaseController {
    private static final Logger log = LoggerFactory.getLogger(AppUserRedRewardController.class);

    @Autowired
    private IAppUserRedRewardService iAppUserRedRewardService;


    /**
     * 查询待领取红包总钱数
     * @return
     */
    @RequestMapping(value = "totalMoney")
    public ServerResponse<Map> totalMoney() {
        AppUser u = getAppUser();
        if(null == u) {
           return ServerResponse.createByErrorCodeMessage(301,"Token不正确");
        }
        return iAppUserRedRewardService.getTotalMoney(u.getUserId());
    }


    /**
     * 红包领取通用（参数前端传）
     * @param
     * @return
     */
    @RequestMapping(value = "receiveMoney",method = RequestMethod.GET)
    public ServerResponse updateHbStatus(AppUserRedReward appUserRedReward) {
        return iAppUserRedRewardService.updateHbStatus(appUserRedReward);
    }

    /**
     * 获取邀请赚钱的所有粉丝及红包
     * @return
     */
    @RequestMapping(value = "invitationMoneyList",method = RequestMethod.GET)
    public ServerResponse getMoneyListHbType() {
        AppUser u = getAppUser();
        if(null == u) {
           return ServerResponse.createByErrorCodeMessage(301,"Token不正确");
        }
        return iAppUserRedRewardService.getMoneyListHbType(u.getUserId());
    }

    /**
     * 未登录红包弹窗--新
     * @return
     */
    @RequestMapping(value = "/getNotLoginRedMoney")
    public ServerResponse getNotLoginRedMoney() {
        return iAppUserRedRewardService.getNotLoginRedMoney();
    }


    /**
     * 邀请赚钱文案
     * @return
     */
    @RequestMapping(value = "/invitationDesc")
    public ServerResponse invitationDesc() {
        return iAppUserRedRewardService.invitationDesc() ;
    }
}
